<?php

namespace App\Models\Divide;

use Illuminate\Database\Eloquent\Factories\HasFactory;
use Illuminate\Database\Eloquent\Model;
use Illuminate\Database\Eloquent\SoftDeletes;

class Category extends Model
{
    use HasFactory,SoftDeletes;
    public $timestamps  = false;
    protected $primaryKey = 'category_id';
    protected function serializeDate(\DateTimeInterface $date)
    {
        return $date->format('Y/m/d H:i:s');
    }
    protected $guarded = [];
    protected function getData ($value){
        return $value?json_decode($value,true):[];
    }
    protected function setData($value){
        if(is_array($value)){
            return json_encode($value);
        }else{
            return $value;
        }
    }
    public function setCategoryTypesAttribute($value)
    {
        $this->attributes['category_types'] = $this->setData($value);
    }
    public function getCategoryTypesAttribute($value){
        return $this->getData($value);
    }
}
